SynthTracker

part of wslib

Synthtracker is a tracking and bookkeeping system for synths based on SynthDef names. It keeps track of all running Synths by name and order of execution.

!! SYNTHTRACKER ONLY WORKS WITH ONE SERVER RUNNING !!

Usage

Use like Synth:

SynthTracker("default");

SynthTracker("default", ['freq', 550]);

Free the first running synth:

SynthTracker.free("default");

Evaluate the line above again to free the second one.

Releasable synths can be released instead of free-d by giving them a flag:

SynthTracker("default", canRelease: true);

SynthTracker.release("default");

If a Synth's canRelease flag is false the Synth will be free-d instead.

Methods for running new Synths

*new( defName, args: [arg1, value1,...argN, valueN], canRelease, maxCount, addAction)

Create and return a new Synth object, and immediately start the corresponding synth node

on the server. Similar to Meta_Synth-new, but the synth is also added to SynthTracker's global

synth library.

defName - A String or Symbol specifying the name of the SynthDef to use in creating the Synth.

args - An optional array specifying initial values for the SynthDef's arguments (controls). These are specified in pairs of control name or index and value. If names are used they can be specified with Symbols. e.g. [\frequency, 440, \amplitude, 1, ...]

argsArray can also be an Event or Dictionary with Symbols as arg names.

e.g. (frequency: 440, amplitude: 1, ...)

canRelease - A Boolean to tell SynthTracker if the Synth created from this defName can be released using Synth.release. This means it should be able to be free-ed internally by setting a 'gate' argument to 0. This flag is stored in the global SynthTracker library for the defName, so it only needs to be specified once per boot. Note that for the "default" defName this flag is set to true by default.

maxCount - A Number stating the maximum number of Synths with the specified defName should be running at once after this one is created. If this number of Synths with this name is already running no new Synth will be created. The default for this argument is inf.

addAction - one of the following Symbols:

\addToHead - (the default) add at the head of the group specified by target

\addToTail - add at the tail of the group specified by target

\addAfter - add immediately after target in its server's node order

\addBefore - add immediately before target in its server's node order

\addReplace - replace target and take its place in its server's node order

*replace( defName, args: [arg1, value1,...argN, valueN], canRelease, maxCount, addAction)

Same as above but here the last already running synth will be released and a new one will be started in place. If maxCount is greater than 1 (default) no synth is replaced until the maxCount is reached. The first synth to be replaced is always the one which started first

*toggle( defName, args: [arg1, value1,...argN, valueN], canRelease, maxCount, addAction)

Same as above but if maxCount Synths are running already one will be released and no new one will be started. Use this to turn synths on and off sequentially. e.g:

Routine({

6.do({

SynthTracker.toggle("default", (freq: 440 + 220.rand2), maxCount: 2);

1.wait; });

SynthTracker.releaseAll;

}).play;

.